package com.itbaima.csmall.order.webapi.mapper;

import com.itbaima.csmall.commons.pojo.order.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>订单数据访问层</p>
 *
 * @author Chen
 * @since 2023/2/20 12:41:41
 */
@Mapper
public interface OrderMapper {

    /**
     * 新增订单
     *
     * @param order 订单
     */
    @Insert("INSERT INTO order_tbl(user_id,commodity_code,count,money) VALUES (#{userId},#{commodityCode},#{count},#{money})")
    void insertOrder(Order order);

    /**
     * <p>分页查询所有订单</p>
     * 使用PageHelper框架完成分页查询原理是在SQL语句运行时，会在SQL语句后添加LIMIT关键字
     *
     * @return 所有订单
     */
    @Select("SELECT id, user_id, commodity_code, count, money FROM order_tbl")
    List<Order> findAllOrders();

}
